﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace System.Linq
{
    public static class EnumerableEx
    {
        /// <summary>
        /// Enumerates the sequence and invokes the given action for each value in the sequence.
        /// 
        /// </summary>
        /// <typeparam name="TSource">Source sequence element type.</typeparam><param name="source">Source sequence.</param><param name="onNext">Action to invoke for each element.</param>
        public static void ForEach<TSource>(this IEnumerable<TSource> source, Action<TSource> onNext)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (onNext == null)
                throw new ArgumentNullException("onNext");
            foreach (TSource source1 in source)
                onNext(source1);
        }
    }
}
